import bot from "../model/bot/amesu";
import func from "../model/func";
import { mathList } from "../model/msgHandle/packge";
import { MsgAction, Tpl_msgMiss } from "../shared/master/MsgAction";
let locaMap:Map<string,string> = new Map()
export default function (data: MsgAction) {
    let d = data.data as Tpl_msgMiss;
    let msg = d.str;
    if(locaMap.has(msg)){
        bot.sendText(data.tolocation, locaMap.get(msg) || '错误的内容');
        return;
    }
    // bot.sendText(data.tolocation,str || '错误的内容');
    let matchList = [...mathList]

    matchList = matchList.filter((item)=>{
        return item.isHideMath
    })
    matchList.sort(function (A, B) {
        return func.xsd(msg, B.mathStr) - func.xsd(msg, A.mathStr);
    });
    if (func.xsd(msg, matchList[0].mathStr) == 0) {
        let arr = matchList
        arr.sort(() => {
            return Math.random() - 0.5
        })

    }
    let temp = `╭°❀•°你想找什么•❀╮\n`;
    for (let index = 0; index < 15; index++) {
        let item = matchList[index];
        if (!item) {
            break;
        }
        if(func.xsd(msg, item.mathStr) > 0){
            temp += `⭐⭐[${item.mathStr}]⭐⭐`;
        }else{
            temp += `@机器人  ${item.mathStr}`;
        }
  
        temp += `\n`
    }
    temp += `╰°•❀°.                       °•❀╯`;
    bot.sendText(data.tolocation, temp || '错误的内容');
}